// This is unpublished source code. Michah Lerner 2006

package trieMatch.util.aggregation;

import trieMatch.Constants;
import trieMatch.Interfaces.Aggregator;

/**
 * Aggregation
 * 
 * @author Michah.Lerner
 * 
 */
public abstract class AggregatorBase implements Aggregator {
	int increment = Constants.AGGREGATION_INCR;

	public AggregatorBase() { // intentionally blank;
	}

	public AggregatorBase(final String increment) {
		this(Integer.parseInt(increment));
	}

	public AggregatorBase(final Integer arg) {
		this();
	}

	static public Aggregator getAggregator(final String aggregatorName, final String aggregatorParm) {
		Aggregator aggregator = Constants.DEFAULT_AGGREGATOR;
		try {
			final Class<?> aggregatorClass = Class.forName(Constants.DEFAULT_AGGREGATOR_BASE + "." + aggregatorName);
			aggregator = (Aggregator) (aggregatorParm == null ? aggregatorClass.getConstructor().newInstance() : aggregatorClass
					.getConstructor(String.class).newInstance(aggregatorParm));
		} catch (final Exception e) {
			e.printStackTrace();
		}
		return aggregator;
	}
}
